#include<bits/stdc++.h>
using namespace std;
#define int long long

struct node {
	int x, y, step;
};

int dx[] = {-1, 0, 1, 0};
int dy[] = {0, 1, 0, -1};

char ch[15][15];
bool vis[15][15];

int qx, qy, zx, zy;

void bfs() {
	queue<node> q;
	q.push({qx, qy, 0});
	vis[qx][qy] = 1;

	while (!q.empty()) {
		node t = q.front();
		q.pop();

		if (t.x == zx && t.y == zy) {
			cout << t.step - 1;
			return ;
		}

		for (int i = 0; i < 4; i++) {
			int xx = t.x + dx[i];
			int yy = t.y + dy[i];

			if (xx < 1 || xx > 10 || yy < 1 || yy > 10 || vis[xx][yy] || ch[xx][yy] == 'R')
				continue;

			q.push({xx, yy, t.step + 1});
			vis[xx][yy] = 1;
		}
	}
}

signed main() {
	for (int i = 1; i <= 10; i++) {
		for (int j = 1; j <= 10; j++) {
			cin >> ch[i][j];
			if (ch[i][j] == 'L')
				qx = i, qy = j;
			if (ch[i][j] == 'B')
				zx = i, zy = j;
		}
	}

	bfs();
	return 0;
}
